package com.moss.cloud.common.webflux.component;

import com.moss.cloud.common.core.model.dto.MessageDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Slf4j
@Component
public class MessageEventSender {
    @Resource
    RocketMQTemplate rocketMQTemplate;

    /**
     * 发送消息
     *
     * @param topic
     * @param messageDTO
     */
    public void sendMessage(String topic, MessageDTO messageDTO) {
        log.info("发送消息->消息主题:{},->消息内容:{}", topic, messageDTO.toString());
        rocketMQTemplate.convertAndSend(topic, messageDTO);
    }
}
